﻿<%@page import="com.demoweb.model.dto.Board"%>
<%@page import="com.demoweb.model.dto.Membership"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FLAPPY FISH</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="/demoweb/styles/flappystyle.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript">
	function viewboard(boardno) {
		
		<%
		String pageNo = request.getParameter("pageno");
		if (pageNo == null || pageNo.length() == 0)
			pageNo = "1";
		%>
		
		<% if (session.getAttribute("loginuser") != null) { %>
		location.href = 
			'view.action?boardno=' + boardno + "&pageno=<%= pageNo %>";
		<% } else { %>
		location.href = 
			"/flappy/account/loginform.action?" + 
			"returnuri=/flappy/board/view.action?boardno=" + 
			boardno + "&pageno=<%= pageNo %>";
		<% } %>
	}
	</script>
</head>
<body>

<%	pageContext.include("/WEB-INF/views/flappy/header.jsp");%>

<div id="content">
  <div id="sidebar">
      <% pageContext.include("/WEB-INF/views/flappy/flappylogin.jsp"); %>
    <% pageContext.include("/WEB-INF/views/flappy/board/boardmenu.jsp"); %>
  </div>
  
  <!-- ---------------------------------- Main page content ----------------------------------- -->
  <div id="main" style="width: 480px; margin-left: 50px; margin-top: 100px; background-color: white;"> 
  	  <h2 class="title">Fortress Board</h2>
  	  
  	  <%!String getTitleString(Board board) {
	
		StringBuilder html = new StringBuilder(256);
		if (board.isDeleted()) {
			html.append("<span style='color:gray' ");
			html.append("onclick=\"alert('삭제된 글입니다.');\">");
			html.append(board.getTitle());
			html.append("&nbsp;(삭제된 글)");
			html.append("</span>");
		} else {
			html.append("<a href='javascript:viewboard(");
			html.append(board.getBoardNo());
			html.append(");'>");
			html.append(board.getTitle());
			html.append("</a>");
		}
			return html.toString();
		}%>

	
	<div id="pageContainer">
		
		<div style="padding-top:25px;text-align:center">

			
			
			<% List<Board> boards = (List<Board>)request.getAttribute("boards"); %>
			<% if (boards != null && boards.size() > 0) { %>
			<table border="1" align="center">
				<tr style="background-color:beige;height:25px">
					<th style="width:50px">번호</th>
					<th style="width:300px">제목</th>
					<th style="width:150px">작성자</th>
					<th style="width:120px">작성일</th>
					<th style="width:80px">조회수</th>
				</tr>
				<% for (Board board : boards) { %>				
				<tr style="height:25px">
					<td style="text-align:center"><%= board.getBoardNo() %></td>
					<td style="text-align:left;padding:5px">
						<%-- 
						<a href="view.action?boardno=<%= board.getBoardNo() %>">
						--%>
						<%-- 
						<a href="javascript:viewboard(<%= board.getBoardNo() %>);">
						<%= board.getTitle() %>
						</a>
						--%>
						<%= getTitleString(board) %>
					</td>
					<td style="text-align:center"><%= board.getWriter() %></td>
					<td style="text-align:center"><%= board.getRegDate() %></td>
					<td style="text-align:center"><%= board.getReadCount() %></td>
				</tr>
				<% } %>
			</table>
			<% } else { %>
				<div style='text-align:center'>등록된 게시물이 없습니다.</div>
			<% } %>
			<br /><br />
			<input type="button" value="글쓰기" style="width:100px;height:25px;margin-left: 380px" onclick="location.href='/flappy/board/writeform.action';" />
			<br /><br />
			
			<%= request.getAttribute("pager").toString() %>
		
		</div>
	</div>
  </div>
</div>
<div id="footer" style="margin-top: 568px; float: inherit">
  <p id="legal">Copyright &copy; 2007 Red Avenue. All Rights Reserved. Designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
  <p id="links"><a href="http://www.free-css.com/">Home</a> | <a href="http://www.free-css.com/">Terms of Use</a></p>
</div>
</body>
</html>  



